Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2AudioManager = require("AudioManager");
var def_QQ_VideoMgr = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    this._rewardVideoAd = new Map();
    this._rewardcomplat = new Map();
  }
  return babel_createClass(_ctor, [{
    key: "Create",
    value: function Create(e, t) {
      var _this74 = this;
      this._rewardcomplat.set(e, t);
      var n = this;
      if (0 == this._rewardVideoAd.has(e)) {
        console.log("创建视频", e);
        var _t40 = window.qq.createRewardedVideoAd({
          adUnitId: e,
          multiton: true
        });
        _t40.onError(function (t) {
          console.log(t.errCode);
          cc.game.resume();
          $2AudioManager.AudioManager.getInstance().resumeAll();
          var _i23 = n._rewardcomplat.get(e);
          null != _i23 && _i23(t.errCode);
        });
        _t40.onClose(function (t) {
          cc.game.resume();
          $2AudioManager.AudioManager.getInstance().resumeAll();
          _this74._rewardVideoAd.get(e).showing = false;
          if (t && t.isEnded) {
            console.log("视频播放完毕", t);
            var _o84 = n._rewardcomplat.get(e);
            if (null != _o84) {
              _o84(true);
              cc.director.emit("MYSELF_TOUCH_END", "playok");
            }
          } else {
            var _t41 = n._rewardcomplat.get(e);
            if (null != _t41) {
              _t41(false);
              cc.director.emit("MYSELF_TOUCH_END", "playfail");
            }
            console.log("中途退出");
          }
        });
        this._rewardVideoAd.set(e, _t40);
      }
    }
  }, {
    key: "destroy",
    value: function destroy(e) {
      if (this._rewardVideoAd.has(e)) {
        this._rewardVideoAd.get(e).destroy();
        this._rewardVideoAd.delete(e);
        this._rewardcomplat.delete(e);
      }
    }
  }, {
    key: "playvideo",
    value: function playvideo(e, t) {
      var _this75 = this;
      this.Create(e, t);
      this._rewardVideoAd.get(e).show().then(function () {
        console.log(" 激励视频展示成功 ");
        cc.game.pause();
        $2AudioManager.AudioManager.getInstance().pauseAll();
      }).catch(function () {
        _this75._rewardVideoAd.get(e).load().then(function () {
          _this75._rewardVideoAd.get(e).show().then(function () {
            cc.game.pause();
            $2AudioManager.AudioManager.getInstance().pauseAll();
          });
        }).catch(function () {});
      });
    }
  }], [{
    key: "Instance",
    get() {
      _ctor._instance || (_ctor._instance = new _ctor());
      return _ctor._instance;
    }
  }]);
}();
exports.default = def_QQ_VideoMgr;